package main

import "fmt"

type Read interface {
	ReadBoo()
}

type Write interface {
	WriteBoo()
}

type Boo struct {
}

func (boo *Boo) ReadBoo() {
	fmt.Println("Read a Boo")
}

func (boo *Boo) WriteBoo() {
	fmt.Println("Write a Boo")
}

func main() {
	// b: pair<type:Boo, value:boo{}地址>
	b := &Boo{}

	// r: pair<type:, value:>
	var r Read
	// r: pair<type:Boo, value:boo{}地址>
	r = b

	r.ReadBoo()

	var w Write
	// w: pair<type:Boo, value:boo{}地址>
	w = r.(Write) // 此处断言为什么会成功？ 因为w r具体的type是一致的

	w.WriteBoo()

}
